<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/common.jsp"%>   
<!DOCTYPE html>
<html>
	
	<head>
		<meta charset="UTF-8">
        <link rel="stylesheet" href="${ctx }/css/layui.css">
		<script type="text/javascript" src="${ctx }/js/layer-v1.9.2/layer/layer.js"></script>
        <script type="text/javascript" src="${ctx}/js/layer-v1.9.2/layer/layui.js"></script>
		<script type="text/javascript" src="${ctx }/js/cart/shopping_cart.jsp.js"></script>
		<title>我的购物车</title>
		<style type="text/css">
			.item-invalid .item-label:hover {
			    text-decoration: none;
			}
			.item-invalid .item-label {
			    background: #dadada;
			    color: #5f5f5f;
			}
		</style>
	</head>
	<body>
		<!--头部  开始-->
		<%@include file="../common/header.jsp"%>
		<!--头部  结束-->
		<%-- <%@include file="../common/headerMemberInfo.jsp"%> --%>
		<div class="same container clearfix shopping_cart">
			<div class="search">
				<a href="${ctx }/" class="logo"><img src="${ctx }/images/logo.png" alt="LOGO" /></a>
				<div class="r">
					<input type="text" placeholder="新款服饰抢先看" /><button>1</button>
					<a href="${ctx }/cart/cartPage">
					     <span>我的购物车						  
                            <i><%=cartItemsCount%></i>
                        </span>
                     </a>
				</div>
			</div>
			<div class="progress">
				<img src="${ctx }/images/gwcjd.png" alt="进度条" />
				<p class="nine">
					<span class="a red">购物车</span>
					<span class="b">确认订单</span>
					<span class="b">支付</span>
					<span class="last">完成</span>
				</p>
			</div>
			<div class="all_goods">
				<p class="f18">
					<a href="${ctx }/cart/cartPage?cartType=all"  id="all" class="selected" >全部商品(${allTotal})</a>
					<a href="${ctx }/cart/cartPage?cartType=privilege" id="privilege" >优惠(${privilegeTotal})</a>
					<a href="${ctx }/cart/cartPage?cartType=shortStock" id="shortStock">库存紧张(${shortStockTotal})</a>
				</p>
				<ul>
					<li class="subtitle">
						<span><input type="checkbox" class="checkedAll"/>&nbsp;全选</span>
						<p class="mr">商品</p>	
						<p>商品信息</p>	
						<p>单价(元)</p>
						<p>数量</p>
						<p>金额(元)</p>
						<p class="operate">操作</p>
					</li>
		        <c:if test="${not empty shops  }">
				    <c:forEach var="shops" items="${shops}">
	                    <li class="item">
							<p>
							    <input type="checkbox" />
								<span>店铺：${shops.shopName }</span>
							<%-- 	<a href=""><img src="${ctx }/images/talk.png" alt="联系客服" /></a> --%>
							</p>
							<c:forEach var="cart" items="${shops.cartItems}">
								<div class="product clearfix <c:if test='${cart.isValid =="1"}'>failure</c:if>">
								    <c:choose>
									    <c:when test="${cart.isValid =='1'}">	
									        <span cartId="${cart.id}"  id="invalidCart" class="f_ailure 1">失效</span>
									    </c:when>
									    <c:otherwise>
									        <input type="checkbox" name="items" value="${cart.id}"/>
									    </c:otherwise>
									</c:choose>	
									<div class="name mr"> 
										<a href="${ctx}/goods/queryGoodsDetail?id=${cart.productId}" target="_blank">
											<img src="${cart.picture}" alt="${cart.productName}" />
											<p>${cart.productName}</p>
										</a>
									</div>
								<%-- 	<div>
										<c:set value="${cart.goods_sku_info}" var="skuInfo"/>								    
										<c:choose>
										    <c:when test="${skuInfo != null and skuInfo != '' and skuInfo.split(',')!= null }">	
									             <c:set value="${skuInfo.split(',')}" var="skuInfoArr"/>									       
									             <c:forEach var="sku" items="${skuInfoArr }">								             
										           <span>${sku}</span>
									             </c:forEach>
										    </c:when>
										    <c:otherwise>
										         <span>无规格商品</span>
										    </c:otherwise>
										</c:choose>	
									</div> --%>
									
								<div class="wrap">
								<div class="editable">
								        <c:set value="${cart.goods_sku_info}" var="skuInfo"/>	
								        <c:set value="${cart.goodsSkuList }" var="goodsSkuList"/>						    
										<c:choose>
										    <c:when test="${skuInfo != null && skuInfo != '' && fn:length(fn:split(skuInfo,',')) >0 }">	
									             <c:set value="${fn:split(skuInfo,',')}" var="skuInfoArr"/>									       
									             <c:forEach var="sku" items="${skuInfoArr }">
									                  <c:if test="${fn:indexOf(sku,'颜色') != -1}">
									                      <span class="s_color">${sku}</span><br />
									                  </c:if>
									                  <c:if test="${fn:indexOf(sku,'尺码') != -1}">
									                      <span class="s_size">${sku}</span><br />
									                  </c:if>									                  
									             </c:forEach>
										    </c:when>
										    <c:otherwise>
										         <span class="s_color">无规格商品</span>
										    </c:otherwise>
										</c:choose>	
									<a href="javascript:;">修改</a>
								</div>
								<div class="param_layer border">
									<div class="left l">
									  <c:forEach var="goodsSku" items="${goodsSkuList}" >
									       <c:set value="${goodsSku.goodsSkuValueList }" var="goodsSkuValueList"/>	
									        <c:if test="${fn:indexOf(goodsSku.name,'尺码') !=-1 }">
										      	<div class="clearfix">
													<span>${goodsSku.name }分类</span>
													<p class="size">
													   <c:forEach var="goodsSkuValue" items="${goodsSkuValueList }" varStatus="skuValueStatus">											   
														   <a href="javascript:;" id="${goodsSkuValue.valueId}"  cartId="${cart.id}"   class="<c:if test='${skuValueStatus.index =="0"}'>selected</c:if>" >${goodsSkuValue.valueName }</a>
													   </c:forEach>
													</p>
											     </div>
									        </c:if>
									        <c:if test="${fn:indexOf(goodsSku.name,'颜色') !=-1 }">
										      	<div class="clearfix">
													<span>${goodsSku.name }分类</span>
													<p class="color">
													   <c:forEach var="goodsSkuValue" items="${goodsSkuValueList }" varStatus="skuValueStatus">											   
														   <a href="javascript:;" id="${goodsSkuValue.valueId}"  cartId="${cart.id}"   class="<c:if test='${skuValueStatus.index =="0"}'>selected</c:if>" >${goodsSkuValue.valueName }</a>
													   </c:forEach>
													</p>
											     </div>
									        </c:if>
									  </c:forEach>
										<button class="yes">确定</button>
										<button class="no">取消</button>
									</div>
									<div class="right r">
										<img src="" alt="" />
									</div>
								</div>
							</div>
									<div class="p_rice">									
								      <%--   <c:choose>
										    <c:when test="${cart.discountMarketPrice != null}">
										       <s>${cart.marketPrice}</s>
										       <p class="unit_price">${cart.discountMarketPrice}</p>		
										       <p class="red">${cart.discountRate*10}折</p>
										    </c:when>
										    <c:otherwise>
										       <p class="unit_price">${cart.marketPrice}</p>	
										    </c:otherwise>
										</c:choose>			 --%>
										  <c:choose>
										    <c:when test="${cart.discountMarketPrice != null}">
										       <p class="unit_price">${cart.discountMarketPrice}</p>		
										    </c:when>
										    <c:otherwise>
										       <p class="unit_price">${cart.marketPrice}</p>	
										    </c:otherwise>
										</c:choose>	
									</div>
									<div class="amount tac">
										<span class="minus">-</span>
										<input type="text" value="${cart.quantity}" class="shu" cartId="${cart.id}" goodsSkuInfos="${cart.goods_sku_info}" productId="${cart.productId }"/>
										<span class="add">+</span>
									</div>
									 <c:choose>
										    <c:when test="${cart.discountMarketPrice != null}">
									           <div class="red money">${cart.discountMarketPrice*cart.quantity}</div>	
										    </c:when>
										    <c:otherwise>
									           <div class="red money">${cart.marketPrice*cart.quantity}</div>	
										    </c:otherwise>
										</c:choose>		
									<%-- <div class="operate delete"><a onclick="deleteProduct(this)" id="${cart.id}" target="_self">删除</a></div> --%>
                                    <div class="operate">
                                          <span class="delete"><a onclick="deleteProduct(this)" id="${cart.id}" target="_self">删除</a></span>                                          
                                          <span><a onclick="addFavorites(this)" id="${cart.id}" target="_self">移入收藏</a></span> 
                                    </div>
								</div>
							 </c:forEach>
						</li>
					</c:forEach>
				 </c:if>
				</ul> 
				<div>
					<div class="l">
						<span><input type="checkbox" class="checkedAll">&nbsp;全选</span>
						<span class="deleteChecked">删除</span>
						<span><a onclick="clearShortStockInvalidPorduct()" target="_self">清空失效商品</a></span>
						<span class="moveToFavorites">移动到收藏夹</span>
					</div>	<!-- 
					 <form action="${ctx }/order/tallyOrders"> -->
					<div class="r">
						<span>共有<i class="red sum">0</i>款商品</span>
						<span>总计：<i class="f18 red totalprice">￥0.00</i></span>
						<input type="hidden" id="totalAmount" value=""/>
						<input type="hidden" id="ids" name="ids" value=""/>
						<button class="fff f18 tallyOrders">结算(<i class="tallMonut">0</i>)</button>		
					</div>
				<!-- 	</form>	 -->
				</div>
			</div>
		</div>
		<!--底部-->
		<%@include file="../common/bottom.jsp"%>
	</body>
</html>
